package com.alks.function.mapper.common;

import com.alks.entity.data.entity.PcStitchCollectDeptHead;
import com.alks.entity.data.entity.SdMtlNewKfRep;
import com.alks.entity.data.entity.SdVendor;
import com.alks.function.data.dto.chengKong.assort.SdMtlTypeNewDto;
import com.alks.function.data.dto.chengKong.produce.PcLotHeadDto;
import com.alks.function.data.dto.stockdept.pcfactorystockwork.LotComMtlDto;
import com.alks.function.data.request.back.MtlSubRequest;
import com.alks.function.data.request.procurement.SdVendorRequest;
import com.alks.function.data.request.stockdept.pcfactorystockwork.LotComMtlRequest;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.mapstruct.Mapper;

import java.util.List;
import java.util.Map;

/*回显通用*/
@Mapper
public interface BackMapper {
    /**
     * 查询厂商
     * @return vendorName,vendorNo
     */
    List<Map<String,String>> vendorQuery(String companyId);

    /*厂商-全部查询（查询本公司的厂商和其他公司有而自己公司没有的厂商）*/
    List<Map<String,String>> vendorAllQuery(String companyId);

    /**
     * 根据厂商名字找厂商ID
     * @param vendorName
     * @return
     */
    String getVendorNoByName(String vendorName);


    /**
     * 查询物料类型
     * @return typeName,typeNo
     */
    List<Map<String, String>> mtlTypeQuery();

    /**
     * 查询部门
     * @return deptName,deptNo
     */

    List<Map<String, String>> deptQuery();

    /**
     * 查询入库原因
     * @return slipReason
     */
    List<String> inSlipReasonQuery();

    /**
     * 查询出库原因
     * @return slipReason
     */
    List<String> outSlipReasonQuery();

    /**
     * 查询大中小物料类型
     * @param mtlType
     * @return
     */
    List<Map<String, String>> mtlTypeLMSQuery(String mtlType);


    /*指令通用材料物料查询*/
    List<Map<String, String>> otherLotComMtlBack(String mtlType);

    List<Map<String, String>> getMtlType3();

    List<SdMtlNewKfRep> getMtlName3(@Param("mtlName") String mtlName,@Param("mtlNo") String mtlNo);

    List<String> getMtlSpecs();

    List<String> getMtlUnits();

    /*获取员工数据*/
    List<Map<String, String>> getEmployee(@Param("deptName") String deptName, @Param("name") String name);

    @Select("SELECT VENDOR_NO AS vendorNo,VENDOR_NAME AS vendorName FROM SD_VENDOR WHERE VENDOR_TYPE = #{type}")
    List<Map<String, String>> vendorMoldQuery(String type);
    @Select("SELECT WAREHOUSE_NO FROM SD_WAREHOUSE WHERE WAREHOUSE_NO IS NOT NULL GROUP BY WAREHOUSE_NO")
    List<String> warehouseNos();
    @Select("SELECT AREA_TYPE FROM SD_WAREHOUSE WHERE AREA_TYPE IS NOT NULL GROUP BY AREA_TYPE")
    List<String> areaTypes();

    List<Map<String,String>> getVendorNoByUserName();

    @Select("SELECT DISTINCT ORDER_ID FROM PC_ORDER_HEAD WHERE ORDER_ID LIKE CONCAT('%',#{lot},'%')")
    List<String> getLots(String lot);

    /**
     * 查询库存物料
     * @param request
     * @return
     */
    List<Map<String, String>> getMtlSub(MtlSubRequest request);

    /**
     * 整合后查询厂商
     *
     * @param vendorNo
     * @param vendorName
     * @param companyId
     * @return
     */
    List<Map<String, String>> getVendorQuery(@Param("vendorNo") String vendorNo, @Param("vendorName") String vendorName, @Param("companyId") String companyId);

    /**
     * 整合后查询物料类型
     * @param levelCode
     * @param typeNo
     * @return
     */
    List<Map<String, String>> getMtlType(@Param("levelCode") Integer levelCode, @Param("typeNo") String typeNo);

    /**
     * 制单员查询
     * @return
     */
    @Select("SELECT TECH_PERSON FROM YF_STYLE GROUP BY TECH_PERSON")
    List<String> getChangeOfOrderMakerList();

    /**
     * 码制
     * @param companyId
     * @return
     */
    @Select("select SIZE_CODE as sizeCode,SIZE_NOTICE as sizeNotice from PC_LOT_SIZE_SEQ_NOTICE where COMPANY_ID=#{companyId} order by SIZE_CODE desc")
    List<Map<String,String>> getSizeTypeByName(String companyId);

    @Select("SELECT DISTINCT LINE FROM PC_STITCH_WORKER WHERE LINE IS NOT NULL ")
    List<String> getStitchLine();
    /*获取型体*/
    List<String> getStyleQuery(@Param("style") String style);

    /*查询剩料入库原因*/
    List<Map<String, Object>> getSlReasonQuery(@Param("type") String type);

    /*获取耗品材料*/
    List<Map<String, Object>> getMtrQuery(@Param("type") String type, @Param("mtlName") String mtlName, @Param("companyId") String companyId);

    /*获取耗品类型分类*/
    List<Map<String, Object>> getMtrTypeQuery();

    /*获取耗品出入库原因*/
    List<String> getMtrReasonQuery(@Param("type") String type);

    /*查询缴库部门数据*/
    List<Map<String, Object>> getStcColQuery(@Param("type") Integer type,@Param("companyId") String companyId);
    

    /*查询通用材料数据*/
    List<LotComMtlDto> getLotComMtlQuery(LotComMtlRequest request);

    /*查询领用单位*/
    List<Map<String, Object>> getLineColQuery();

    /*基本资料（厂商，仓库之类）*/
    List<Map<String, Object>> getBaseDetailQuery(@Param("baseType") String baseType, @Param("itemName") String itemName, @Param("companyId") String companyId);

    /*返回资料类型集*/
    List<Map<String, Object>> getBaseHeadQuery(@Param("companyId") String companyId);

    /*楦头列表*/
    List<String> getLastTempQuery(@Param("lastNo") String lastNo, @Param("companyId") String companyId);

    @Select("SELECT TYPE_NO,TYPE_NAME FROM YF_MTL_TYPE_NEW WHERE LENGTH(TYPE_NO) = 4")
    List<Map<String, String>> getYfMtlType3();

    @Select("SELECT DISTINCT PHOTO_PATH FROM YF_STYLE_COLOR_DETAIL")
    List<String> getUrl();

    @Delete("UPDATE  YF_STYLE_COLOR_DETAIL SET PHOTO_PATH = NULL WHERE PHOTO_PATH = #{string}")
    Integer deleteUrl(String string);

    @Select("SELECT distinct VENDOR_NAME AS vendorName FROM SD_VENDOR WHERE DEL_FLAG='0' AND VENDOR_NO = #{companyId}  ")
    String getVendorCompanyNameByCompanyId(String companyId);

    /*材料类型回显-查询*/
    List<SdMtlTypeNewDto> getMaterialType(@Param("typeNo") String typeNo);

    /*指令型体回显-查询*/
    List<PcLotHeadDto> getLotNoAndStyle(@Param("lotNo") String lotNo , @Param("companyId") String companyId);

    /*指令回显以20分组-查询*/
    List<PcLotHeadDto> getLotNo(@Param("lotNo") String lotNo, @Param("companyId") String companyId);

    /*获取厂商名字通过no*/
    SdVendor getVendorNameByNo(@Param("vendorNo") String vendorNo, @Param("companyId") String companyId);

    /*费用类型查询*/
    List<Map<String, String>> getPcCostType(@Param("typeNo") String typeNo, @Param("typeName") String typeName, @Param("companyId") String companyId);

    /*根据条件查询所有厂商信息*/
    List<SdVendor> getVendorByCondition(@Param("request") SdVendorRequest request, @Param("companyId") String companyId);

    /**
     * 获取所有指令
     * @param lotNo 指令编号
     * @param companyId 公司id
     * @return 指令编号集合
     */
    List<String> getRyLots(@Param("lotNo") String lotNo, @Param("companyId") String companyId);

    /**
     * 判断指令数
     * @param lotNo 指令号
     * @param companyId 公司ID
     * @param cfmFlag 是否检核 1：已确认
     * @param checkFlag 是否审核 1：已确认
     * @return 指令数
     */
    int getRyLotCount(@Param("lotNo") String lotNo, @Param("companyId") String companyId, @Param("checkFlag") Integer checkFlag, @Param("cfmFlag") Integer cfmFlag);

    List<PcStitchCollectDeptHead> getStcColQuery2(String companyId, String deptName, String deptNo);

    /**
     * 查询存在的指令集合
     * @param lotNoList 指令集合
     * @param companyId 公司ID
     * @return 存在的指令集合
     */
    List<String> getExistRyLotList(@Param("lotNoList") List<String> lotNoList, @Param("companyId") String companyId);

    List<Map<String, String>> getSupplementDept(@Param("searchKey") String searchKey, @Param("companyId") String companyId);

    List<Map<String, String>> getVendorSearch(@Param("search") String search, @Param("companyId") String companyId);

    /**
     * 研发指令查询
     */
    List<String> getOrderId(@Param("search") String search, @Param("companyId") String companyId);

    List<Map<String, Object>> vendorByCI(@Param("companyId") String companyId);

}
